package com.exception;

import cn.hutool.http.HttpStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 自定义异常
 *
 * @author cxt
 * @date 2020/8/31
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApiException extends RuntimeException {
    /**
     * 1、提示信息
     */
    public static final ErrorVM E_USER_EXIST = new ErrorVM(HttpStatus.HTTP_BAD_REQUEST, "手机号已注册");
    public static final ErrorVM F_FILE_EXIST = new ErrorVM(HttpStatus.HTTP_BAD_REQUEST, "文件不存在");
    public static final ErrorVM E_UNAUTHORIZED = new ErrorVM(HttpStatus.HTTP_UNAUTHORIZED, "未登录或者登录过期");

    /**
     * 2、错误信息
     */
    public static final ErrorVM E_SYSTEM_EXIST = new ErrorVM(HttpStatus.HTTP_INTERNAL_ERROR, "手机号已注册");

    private Integer code;
    private String message;
    private Object data;

    public ApiException(ErrorVM fFileExist) {
        this.code = fFileExist.getCode();
        this.message = fFileExist.getMessage();
    }

    public ApiException(String message) {
        this.code = 500;
        this.message = message;
    }

    public ApiException(String message, Object data) {
        this.code = 500;
        this.message = message;
        this.data = data;
    }
}
